package com.example.myapplication.decoration;

import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.State;

/**
 * 注：单纯进行了item的偏移，使item之间产生间距
 */
public class SpannedGridItemDecoration extends RecyclerView.ItemDecoration {
    private final int mDecorationSize;

    public SpannedGridItemDecoration(int decorationSize){
        mDecorationSize = decorationSize;
    }

    @Override
    public void getItemOffsets(Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull State state) {
        outRect.left = mDecorationSize / 2;
        outRect.right = mDecorationSize / 2;
        outRect.top = mDecorationSize / 2;
        outRect.bottom = mDecorationSize / 2;
    }
}
